|
DX11 SET COMPUTE SHADER RWBUFFER
Sets a read/write buffer that can be accessed by the specified compute shader.
You can bind up to 8 different buffer and image resources for read/write access by a compute shader on DX11 hardware. These will use registers u0 through u7.
Only a single read/write resource can be bound at any one time on DX10 hardware (to register u0).
Take note that buffers and textures (as well as render targets, but those aren't applicable to the compute shader; if you use read/write resources in a pixel shader they share slots with render targets
as well however) share the same register slots, thus setting a buffer to slot 1 followed by setting a texture to the same slot will overwrite the previously set buffer.
You can unbind buffers by specifying nullptr as the buffer argument; this is neccessary if the same buffer is bound as a read-only buffer by the same shader since a resource cannot simultaneously
be bound for read-only and read/write access (you can read from the read/write resource as the name suggests though).
Read-write buffers are declared like so in HLSL:
- RWBuffer BufferName : register(t?) where «datatype» can be either bool, int, uint or float and ? ranges between 0 and 7 for array buffers
[DX11 only]
- RWStructuredBuffer BufferName : register(t?) where ? ranges between 0 and 7 (only slot 0 is available on DX10 hardware) for structured buffers
- ByteAddressBuffer BufferName : register(t?) where ? ranges between 0 and 7 (only slot 0 is available on DX10 hardware) for byte address buffers
Note that if you use this function to set an append/consume buffer it will be made available to your shader as a RWStructuredBuffer!
Use DX11 SET COMPUTE SHADER APPEND CONSUME BUFFER to to bind it as a AppendStructuredBuffer or a ConsumeStructuredBuffer.
DX11 SET COMPUTE SHADER RWBUFFER shader, slot, buffer
shader Dword The compute shader to set the writable buffer resource for.
slot Dword The shader register slot to bind the buffer to. The valid range is 0 through 7 on DX11 hardware, or just slot 0 on DX10 hardware. Take note that read/write texture resources use the same register slots.
buffer Dword The buffer to bind to the specified slot of the given compute shader. Note that a non-null buffer must be GPU-writable. Set to nullptr to remove a previously bound buffer / texture from the given slot.
This function does not return a value.
DIRECTCOMPUTE Functions Menu
DX11 Function Categories
|